/*
 * Created by: 	Zhaoningbo
 * at:			2011-8-30 - 上午09:21:19
 * blog:		(http://zhaoningbo.iteye.com/)
 */
package com.gc.action.exception;

import java.io.Serializable;

import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class TimeHandler implements Serializable, MethodInterceptor {

    private static final long serialVersionUID = -8086982531158580646L;
    private Log log = LogFactory.getLog(this.getClass().getName());

    public Object invoke(MethodInvocation methodInvocation) throws Throwable {
        long procTime = System.currentTimeMillis();
        log.info(methodInvocation.getArguments()[0] + "执行"
                + methodInvocation.getMethod() + "方法, 开始.");
        
        Object result = null;
        result = methodInvocation.proceed();
        
        procTime = System.currentTimeMillis() - procTime;
        log.info(methodInvocation.getArguments()[0] + "执行"
                + methodInvocation.getMethod() + "方法, 结束.耗时：" + procTime);
        
        return result;
    }

}
